<?php
namespace app\common\model;
use think\Model;
/**商圈***/
class Area extends Model{
    protected $autoWriteTimestamp=true;
    //添加数据逻辑
    public function add($data){
        $data['status']=1;
        return $this->save($data);
    }
    
    //获取主分类
    public function getNormalFirstArea(){
        $data=[
            "status"=>1,
            "parent_id"=>0,
        ];
        
        $order=[
            "id"=>"desc",
        ];
        
        return $this->where($data)->order($order)->select();
    }
    
    //获取全部子分类
    public function getFirstAreas($parent_id=0){
        $data=[
            "status"=>["neq",-1],
            "parent_id"=>$parent_id,
        ];
        
        $order=[
            "listorder"=>"desc",
            "id"=>"desc",
        ];
        
        $res=$this->where($data)->order($order)->select();
        return $res;
    }
    
    
}

